/*
 *
 *  * Copyright (c) iwindplus Technologies Co., Ltd.2024-2030, All rights reserved.
 *
 *
 */

package com.iwindplus.base.redis.domain.property;

import java.time.Duration;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 通用对象池配置相关属性.
 *
 * @author zengdegui
 * @since 2025/11/01 02:23
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ConfigurationProperties(prefix = "generic-object.pool")
public class GenericObjectPoolProperty {

    /**
     * 是否启用.
     */
    @Builder.Default
    private Boolean enabled = Boolean.TRUE;

    /**
     * 初始大小.
     */
    private Integer bufferSize;

    /**
     * 最多同时借出.
     */
    private Integer maxTotal;

    /**
     * 最多保留空闲.
     */
    private Integer maxIdle;

    /**
     * 最小空闲.
     */
    private Integer minIdle;

    /**
     * 阻塞等待最大时间.
     */
    private Duration maxWait;

    /**
     * 借出连接时不验证，可能拿到已失效的连接.
     */
    @Builder.Default
    private Boolean testOnBorrow = Boolean.FALSE;

    /**
     * 归还连接时不验证，可能把坏连接放回池里.
     */
    @Builder.Default
    private Boolean testOnReturn = Boolean.FALSE;

    /**
     * 当连接耗尽时是否阻塞.
     */
    @Builder.Default
    private Boolean blockWhenExhausted = Boolean.TRUE;
}
